<!DOCTYPE html>
<html>
<head>
	<title></title>
<link rel="stylesheet" type="text/css" href="__INDEX__/css/public.css">
<link rel="stylesheet" type="text/css" href="__INDEX__/css/style.css">
<link rel="stylesheet" type="text/css" href="__INDEX__/css/responsive.css">
<link rel="shortcut icon" href="__INDEX__/images/favorite.ico">
<script src="__INDEX__/js/jquery-1.9.1.min.js"></script>
<script src="__INDEX__/js/public.js"></script>
<script src="__INDEX__/layer/layer.js"></script>
</head>
<body>
<!--添加送货地址弹窗-->
<div class="add_address" id="add_address">
	<div class="">
		<!-- <span class="name">添加送货地址</span> -->
		<form id="from" method="post" action="{:url('Depot/address')}">
			<table cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td class="label_name">收&nbsp;货&nbsp;&nbsp;人：</td>
					<td><input name="user" type="text" value="" class="add_text" style=" width:100px" /><i>*</i></td>
				</tr>
				<tr>
					<td class="label_name">手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机：</td>
					<td><input name="phone" type="text" class="add_text" style=" width:200px" /></td>
				</tr>
				<tr>
					<td colspan="3">
						<select class="province" name="province"></select><select name="city"></select><select name="area"></select>
					</td>
				</tr>
				<tr>
					<td class="label_name">详细地址：</td>
					<td><textarea class="address" name="address_info" cols="" rows=""></textarea><i>*</i></td>
				</tr>
				<tr>
					<td class="label_name">邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编：</td>
					<td><input name="youbian" type="text" class="add_text" value=""  style=" width:100px" /><i>*</i></td>
				</tr>
				<tr>
					<td colspan="2" class="center">
						<input name="" type="button" id="submit" value="保存" class="add_dzbtn" />
						<input name="" type="reset" value="清空" class="reset_btn" /></td>
				</tr>
			</table>
		</form>
	</div>
</div>

<script src="__INDEX__/js/PCASClass.js"></script>
<script src="__INDEX__/js/common.js"></script>
<script>
new PCAS("province", "city", "area");
new PCAS("province1", "city1", "area1");
</script>

<script>
$("#submit").click(function(){
    var user = $("input[name='user']").val();
    var phone = $("input[name='phone']").val();
   	var address = $(".address").val();
    var province = $(".province").val();
    var code = $("input[name='youbian']").val();
    if(user.length==0){
        layer.msg("请输入收件人");
        return false;
    }
    if(phone.match(/^1[34578]\d{9}$/) == null){
        layer.msg("请输入正确手机号码格式");
        return false;
    }
    if(province.length==0){
      	layer.msg("请选择收货地址");
       	return false;
   	}
    if(address.length==0){
        layer.msg("请输入详细地址");
        return false;
    }
    if(code.length==0){
        layer.msg("请输入收件人");
        return false;
    }
    //$('form').submit();
    var url = $("#from").attr("action");
    var data = $('form').serializeArray();
    $.ajax({
        type: 'POST',
        url: url,
        dataType: 'json',
        data: data,
        success: function (data) {
            if( data.result == 0 ){
                layer.open({
                    content: data.msg//
                    ,yes: function(index, layero){
                        window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }
                    ,cancel:function(index){
                        window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }
                });

            }
        }
    });
});

</script>
</body>
</html>